﻿/// <summary>
/// 单例模板
/// </summary>
/// <typeparam name="T"></typeparam>
public abstract class Singleton<T> where T : Singleton<T>, new()
{
    private static T instance = null;

    protected Singleton()
    {
    }

    public static T Instance
    {
        get
        {
            if (instance == null)
            {
                instance = new T();
                instance.AutoInit();
            }
            return instance;
        }
    }

    protected virtual void AutoInit()
    {

    }

    public virtual void Dispose()
    {

    }
}